/* $RCSFile: ADNDynAsyncoperation.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynAsyncoperation.cs $
 * $log$
 * Revision 19 2010/10/02 14:01:48  christian.surieux
 *   Corrected a bug in allmost everyADNDyn file for PrimaryFieldVualue
 * Revision 6 2010/08/06 19:56:32  christian.surieux
 *   Added Log to All cs files
 */

/* Copyrights Christian Surieux 2010 */
/* Class ADNDynAsyncoperation */
/* Date 2010-03-17 19:33:42Z */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynAsyncoperation : DynEntity
	{
		/* Internal class for DynTypes */
		protected class Ftor: DFactor
		{
			public Ftor() : base(CrmStr.asyncoperation){}
			public override Type DynType
			{	get{return typeof(ADNDynAsyncoperation);}}
			public override string DynTypename
			{	get{return CrmStr.asyncoperation;}}
			public override DynEntity Build()
			{	return new ADNDynAsyncoperation();}
			public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
			{	return new ADNDynAsyncoperation(w, dEntity, wproperties, null);}
			public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
			{	return new ADNDynAsyncoperation(w, PrimaryFieldValue);}
			public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
			{	return new ADNDynAsyncoperation(w,PrimaryKeyValue);}
		}
		/* Static Ctor to register in DynTypes */
		static ADNDynAsyncoperation(){new Ftor();}

		public override bool HasOwningBusinessUnitProperty
		{	get{ return true;}}
		public ADNDynAsyncoperation(): base(){}
		public ADNDynAsyncoperation(CRMWrapperBase w, string PrimaryFieldValue): base(w, CrmStr.asyncoperation)
		{
			if ( PrimaryFieldValue != string.Empty )
			name	=   PrimaryFieldValue;
		}
		public ADNDynAsyncoperation(CRMWrapperBase w, Guid CrmId): base(w,CrmStr.asyncoperation, CrmId){}
		public ADNDynAsyncoperation(CRMWrapperBase w, InternalDynamicEntity e): base(w,CrmStr.asyncoperation,e,null,null){}
		public ADNDynAsyncoperation(CRMWrapperBase w, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s): base(w,CrmStr.asyncoperation,e,prop,s){}
		public ADNDynAsyncoperation(ResetWrapperHandler fn, string PrimaryFieldValue): base(fn,CrmStr.asyncoperation)
		{
			if ( PrimaryFieldValue != string.Empty )
				name	=   PrimaryFieldValue;
		}
		public ADNDynAsyncoperation(ResetWrapperHandler fn, Guid CrmId): base(fn,CrmStr.asyncoperation,CrmId){}
		public ADNDynAsyncoperation(ResetWrapperHandler fn,InternalDynamicEntity e): base(fn,CrmStr.asyncoperation,e,null,null){}
		public ADNDynAsyncoperation(ResetWrapperHandler fn,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s): base(fn,CrmStr.asyncoperation,e,prop,s){}

		/* Properties */

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public Guid asyncoperationid
		{
		get	{	 return KeyPropertyValue(CrmStr.asyncoperationid);}
		set	{	AddKeyProperty(CrmStr.asyncoperationid, value);}
		}
		protected override void SetCrmIdProperty(Guid crmId)
		{
			if ( !dicProperty.ContainsKey(CrmStr.asyncoperationid)  || KeyPropertyValue(CrmStr.asyncoperationid) != crmId )
				asyncoperationid	=   crmId;
		}
		public override Guid PrimaryKeyGuidValue
		{
		    get	{	return asyncoperationid;}
		    set{	asyncoperationid	=value;}
		}
		
        public override string PrimaryFieldName
		{
		    get	{	return CrmStr.name;}
		    set	{}
		}

        public override string PrimaryFieldStringValue
        {
            get
            {
                return name;
            }
            set
            {
                name =   value;
            }
        }

        [CrmDynAttribute(CrmStr.asyncoperation)]
		public string completedon
		{
		    get	{	 return DateTimePropertyValue(CrmStr.completedon);}
		    set	{	AddDateTimeProperty(CrmStr.completedon, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public Guid correlationid
		{
		    get	{	 return UniqueIdentifierPropertyValue(CrmStr.correlationid);}
		    set	{	AddUniqueIdentifierProperty(CrmStr.correlationid, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string correlationupdatedtime
		{
		    get	{	 return DateTimePropertyValue(CrmStr.correlationupdatedtime);}
		    set	{	AddDateTimeProperty(CrmStr.correlationupdatedtime, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string data
		{
		    get	{	 return StringPropertyValue(CrmStr.data);}
		    set	{	AddStringProperty(CrmStr.data, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string dependencytoken
		{
		    get	{	 return StringPropertyValue(CrmStr.dependencytoken);}
		    set	{	AddStringProperty(CrmStr.dependencytoken, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public int depth
		{
		    get	{	 return NumberPropertyValue(CrmStr.depth);}
		    set	{	AddNumberProperty(CrmStr.depth, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public int errorcode
		{
		    get	{	 return NumberPropertyValue(CrmStr.errorcode);}
		    set	{	AddNumberProperty(CrmStr.errorcode, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string hostid
		{
		    get	{	 return StringPropertyValue(CrmStr.hostid);}
		    set	{	AddStringProperty(CrmStr.hostid, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public bool iswaitingforevent
		{
			get	{	 return BooleanPropertyValue(CrmStr.iswaitingforevent);}
    		set	{	AddBooleanProperty(CrmStr.iswaitingforevent, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string message
		{
		    get	{	 return StringPropertyValue(CrmStr.message);}
		    set	{	AddStringProperty(CrmStr.message, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string messagename
		{
		    get	{	 return StringPropertyValue(CrmStr.messagename);}
		    set	{	AddStringProperty(CrmStr.messagename, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public override string name
		{
		    get	{	 return StringPropertyValue(CrmStr.name);}
		    set	{	AddStringProperty(CrmStr.name, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public int operationtype
		{
		    get	{	 return PicklistPropertyIntValue(CrmStr.operationtype);}
		    set	{	AddPicklistProperty(CrmStr.operationtype,value);}
		}

		public string operationtypeLabel
		{
    		get	{	 return PicklistPropertyLabelValue(CrmStr.operationtype);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public Guid owningbusinessunit
		{
		    get	{	 return LookupPropertyValue(CrmStr.owningbusinessunit);}
		    set	{	AddLookupProperty(CrmStr.owningbusinessunit,CrmStr.businessunit,value);}
		}

		public string businessunitName
		{
    		get	{	 return LookupPropertyName(CrmStr.owningbusinessunit);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public Guid owninguser
		{
		    get	{	 return LookupPropertyValue(CrmStr.owninguser);}
		    set	{	AddLookupProperty(CrmStr.owninguser,CrmStr.systemuser,value);}
		}

		public string systemuserName
		{
    		get	{	 return LookupPropertyName(CrmStr.owninguser);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string postponeuntil
		{
		    get	{	 return DateTimePropertyValue(CrmStr.postponeuntil);}
		    set	{	AddDateTimeProperty(CrmStr.postponeuntil, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string primaryentitytype
		{
		    get	{	 return StringPropertyValue(CrmStr.primaryentitytype);}
		    set	{	AddStringProperty(CrmStr.primaryentitytype, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string primaryentitytypename
		{
		    get	{	 return StringPropertyValue(CrmStr.primaryentitytypename);}
		    set	{	AddStringProperty(CrmStr.primaryentitytypename, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string recurrencepattern
		{
		    get	{	 return StringPropertyValue(CrmStr.recurrencepattern);}
		    set	{	AddStringProperty(CrmStr.recurrencepattern, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string recurrencestarttime
		{
		    get	{	 return DateTimePropertyValue(CrmStr.recurrencestarttime);}
		    set	{	AddDateTimeProperty(CrmStr.recurrencestarttime, value);}
		}

        protected string _DefaultRegardingObjectName   =   CrmStr.account;
		public virtual string DefaultRegardingObjectName // TBD redefine for each specific activity
		{
			get
			{
				return _DefaultRegardingObjectName;
			}
			set
			{
                /*
                switch (value)
                {
                    case CrmStr.account:
                    case CrmStr.contact:
                    case CrmStr.bulkoperation: // ie quick campaign, ok for mail
                    case CrmStr.campaign:  //beware, not valid for emails, only campaignactivity allowed
                    case CrmStr.campaignactivity:
                    case CrmStr.incident:
                    case CrmStr.contract:
                    case CrmStr.invoice:
                    case CrmStr.lead:
                    case CrmStr.opportunity:
                    case CrmStr.salesorder:
                    case CrmStr.quote:
activitymimeattachment
activitypointer
annotation
annualfiscalcalendar
appointment
attributemap
bulkoperation
bulkoperationlog
businessunit
businessunitnewsarticle
calendar
campaignresponsecompetitor
constraintbasedgroup
contractdetail
contracttemplate
customeraddress
customeropportunityrole
customerrelationship
discount
discounttype
displaystring
email
entitymap
equipment
fax
fixedmonthlyfiscalcalendar
import
importfile
importlog
importmap
incident
incidentresolution
invoice
invoicedetail
isvconfig
kbarticle
kbarticlecomment
kbarticletemplate
lead
letter
list
mailmergetemplate
monthlyfiscalcalendar
opportunity
opportunityclose
opportunityproduct
orderclose
organization
organizationui
phonecall
pricelevel
privilege
product
productpricelevel
quarterlyfiscalcalendar
queue
queueitem
quote
quoteclose
quotedetail
relationshiprole
relationshiprolemap
report
resource
resourcegroup
resourcespec
role
salesliterature
salesliteratureitem
salesorder
salesorderdetail
savedquery
semiannualfiscalcalendar
service
serviceappointment
site
subject
systemuser
task
team
template
territory
transactioncurrency
uom
uomschedule
userquery */

                        _DefaultRegardingObjectName  =   value;
   //                     break;
   //             }
			}
		}

        /// <summary>
        /// Gets or sets the ID of the entity instance with which the activity is associated. 
        /// </summary>
		[CrmDynAttribute(CrmStr.asyncoperation)]
        public Guid regardingobjectid
        {
            get
            {
                return LookupPropertyValue(CrmStr.regardingobjectid);
            }
            set
            {
                AddLookupProperty(CrmStr.regardingobjectid,DefaultRegardingObjectName,value);
            }
        }

        public string regardingobjectType
        {
            get
            {
                return LookupPropertyType(CrmStr.regardingobjectid);
            }
        }

		public string regardingobjectName
		{
		get	{	 return LookupPropertyName(CrmStr.regardingobjectid);}
		}


		[CrmDynAttribute(CrmStr.asyncoperation)]
		public Guid requestid
		{
		get	{	 return UniqueIdentifierPropertyValue(CrmStr.requestid);}
		set	{	AddUniqueIdentifierProperty(CrmStr.requestid, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public int retrycount
		{
		get	{	 return NumberPropertyValue(CrmStr.retrycount);}
		set	{	AddNumberProperty(CrmStr.retrycount, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string startedon
		{
		get	{	 return DateTimePropertyValue(CrmStr.startedon);}
		set	{	AddDateTimeProperty(CrmStr.startedon, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public int timezoneruleversionnumber
		{
		get	{	 return NumberPropertyValue(CrmStr.timezoneruleversionnumber);}
		set	{	AddNumberProperty(CrmStr.timezoneruleversionnumber, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public Guid workflowactivationid
		{
		get	{	 return LookupPropertyValue(CrmStr.workflowactivationid);}
		set	{	AddLookupProperty(CrmStr.workflowactivationid,CrmStr.workflow,value);}
		}

		public string workflowactivationName
		{
		get	{	 return LookupPropertyName(CrmStr.workflowactivationid);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public bool workflowisblocked
		{
			get	{	 return BooleanPropertyValue(CrmStr.workflowisblocked);}
		set	{	AddBooleanProperty(CrmStr.workflowisblocked, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string workflowstagename
		{
		get	{	 return StringPropertyValue(CrmStr.workflowstagename);}
		set	{	AddStringProperty(CrmStr.workflowstagename, value);}
		}

		[CrmDynAttribute(CrmStr.asyncoperation)]
		public string workflowstate
		{
		get	{	 return StringPropertyValue(CrmStr.workflowstate);}
		set	{	AddStringProperty(CrmStr.workflowstate, value);}
		}

	}
}